import Vue from 'vue';
import App from './App';

Vue.config.productionTip = false;
Vue.config.devtools = true

// 定义一个 Vue 全局的过滤器，名字叫做 numberformat
// Vue.filter('numberformat', function(price) {
// 	console.log('numberformat', price);
// })

Vue.mixin({
	methods: {
		setData: function(obj, callback) {
			let that = this;
			let keys = [];
			let val, data;
			Object.keys(obj).forEach(function(key) {
				keys = key.split('.');
				val = obj[key];
				data = that.$data;
				keys.forEach(function(key2, index) {
					if (index + 1 == keys.length) {
						that.$set(data, key2, val);
					} else {
						if (!data[key2]) {
							that.$set(data, key2, {});
						}
					}
					data = data[key2];
				})
			});
			callback && callback();
		}
	}
});

App.mpType = 'app';

const app = new Vue({
	...App
});
app.$mount();
